<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">
<style>
    .city-picker-span{height: 28px !important;overflow: hidden;}
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">所属单位</label>
                        <div class="layui-input-block">
                            <div id="chanid" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">人员姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">员工编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">身份证号</label>
                        <div class="layui-input-block">
                            <input type="text" name="idcard" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                            <select name="sex" lay-filter="sex" >
                                <option value="">请选择</option>
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">学历</label>
                        <div class="layui-input-block">
                            <select id="xueli" name="xueli" lay-filter="xueli"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">专业</label>
                        <div class="layui-input-block">
                            <input type="text" name="major" id="major" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">人员性质</label>
                        <div class="layui-input-block">
                            <select id="nature" name="nature" lay-filter="nature"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">入职日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="intodt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">人员状态</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">离职日期</label>
                        <div class="layui-input-block">
                            <input type="text" name="outdt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymd">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">社保状态</label>
                        <div class="layui-input-block">
                            <select id="social" name="social" lay-filter="social"></select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">参保地</label>
                        <div class="layui-input-block">
                            <input type="text" name="socarea" id="socarea" placeholder="请输入" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">参保开始月份</label>
                        <div class="layui-input-block">
                            <input type="text" name="socstartdt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ym">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>
    var currButAuth, currTabData;
    layui.use(['table','form','soulTable'], function () {
        var table = layui.table, form = layui.form, soulTable = layui.soulTable;

        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('员工档案');
        table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_person_list),where: {state: '在职'}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);

                xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })

                xiala_zhan_one_you('xueli', res.data.xueli, res.data.is_xueli);
                xiala_zhan_one_you('nature', res.data.nature, res.data.is_nature);
                xiala_zhan_one_you('social', res.data.social, res.data.is_social);
                xiala_zhan_one_you('state', res.data.state, res.data.is_state);


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type: 'numbers',title:'序号',fixed:'left'}
                ,{field: 'name', title: '姓名',fixed:'left'}
                ,{field: 'number', title: '员工编号'}
                ,{field: 'sex', title: '性别'}
                ,{field: 'age', title: '年龄'}
                ,{field: 'idcard', title: '身份证号',hide:true}
                ,{field: 'xueli', title: '学历',hide:true}
                ,{field: 'major', title: '专业',hide:true}
                ,{field: 'gangid_name', title: '岗位'}
                ,{field: 'nature', title: '人员性质'}
                ,{field: 'intodt', title: '入职日期',hide:true}
                ,{field: 'state', title: '状态'}
                ,{field: 'chanid_name', title: '所属单位'}
                ,{field: 'deptid_name', title: '所在部门'}
                ,{field: 'outdt', title: '离职日期',hide:true}
                ,{field: 'laokaidt', title: '合同开始日期',hide:true}
                ,{field: 'laojiedt', title: '合同结束日期',hide:true}
                ,{field: 'social', title: '社保状态'}
                ,{field: 'socarea', title: '参保地'}
                ,{field: 'socstartdt', title: '参保开始月份'}
                ,{field: 'socenddt', title: '参保结束月份',hide:true}
                ,{field: 'socnum', title: '连续参保月份数'}
                ,{field: 'shenum', title: '社保卡号',hide:true}
                ,{field: 'gongnum', title: '公积金号',hide:true}
                ,{field: 'social_explain', title: '社保说明',hide:true}
                ,{field: 'bankname', title: '账户名',hide:true}
                ,{field: 'banknum', title: '账号',hide:true}
                ,{field: 'bankkai', title: '开户行',hide:true}
                ,{field: 'explain', title: '备注',hide:true}
                ,{field: 'certnum', title: '证书数量'}
                ,{field: 'filesnum', title: '附件'}
                ,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo',align:'center',width:200}
            ]]
            , done: function (res) {
                soulTable.render(this);

                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });
        listTableSearch(form, table);
    });

    function auth_but_func_show(buttitle, index){
        var trData = currTabData[index];
        openPage('show.php?id='+trData.id);
    }
    function auth_but_func_add(){
        openPageEdit('add.php?close=1');
    }
    function auth_but_func_edit(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('edit.php?close=1&id='+trData.id);
    }
    function auth_but_func_delete(buttitle, index){
        var trData = currTabData[index];
        data_delete(ask_person_del, {id:trData.id});
    }


    function auth_but_func_addcert(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('../cert/add.php?close=1&personid='+trData.id);
    }
    function auth_but_func_editout(buttitle, index){
        var trData = currTabData[index];
        openPageEdit('editout.php?id='+trData.id);
    }
    function auth_but_func_import(buttitle){
        openPage('../public/import.php?url='+ask_import_person+'&down='+encodeURIComponent('人员')+'&daolei=1', '770px', '490px');
    }
    function auth_but_func_muldel(buttitle){
        var idArr = get_table_check_idarr();
        if(idArr.length < 1){
            facade.error(buttitle + "：请选择数据");return false;
        }
        data_delete(ask_person_del, {id: idArr.join(',')});
    }

    function auth_but_func_out(buttitle, index){
        openNavPage(buttitle,'person_out/index.php');
    }

</script>
</body>
</html>
